﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Common;
using System.Linq;
using System.Text;
using WMSADBUtility;

namespace ElectronicWMSA.List.Second
{
    public class ExcelLog_DAL
    {

        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        /// <param name="NID"></param>
        /// <returns></returns>
        public ExcelLog_Entity GetEntity(int Nid)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("SELECT TOP 1 ExcelName,ExcelFile FROM T_Excel_Log where Nid ='" + Nid + "'" );
            Database db = DatabaseFactory.CreateDatabase();
            DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());
            ExcelLog_Entity entity = null;
            using(IDataReader dataReader = db.ExecuteReader(dbCommand))
            {
                if(dataReader.Read())
                {
                    entity = ReaderBind(dataReader);
                }
            }
            return entity;
        }

        /// <summary>
        /// 对象实体绑定数据
        /// </summary>
        /// <param name="dataReader"></param>
        /// <returns></returns>
        public ExcelLog_Entity ReaderBind(IDataReader dataReader)
        {
            ExcelLog_Entity entity = new ExcelLog_Entity();
            entity.ExcelName = dataReader["ExcelName"].ToString();
            object v = dataReader["ExcelFile"];
            entity.ExcelFile = (byte[])v;
            return entity;
        }


     }
}
